﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GPMS.Model
{
    /// <summary>
    /// 可分页的泛型实体
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Pagination<T> : List<T> where T : class
    {
        public int pageSize { get; private set; }
        public int pageIndex { get; private set; }
        public int itemsCount { get; private set; }

        /// <summary>
        ///创建一个带分页属性的实体
        /// </summary>
        /// <param name="data">数据List</param>
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageIndex">页数</param>
        /// <param name="itemsCount">总数据量</param>
        public Pagination(IList<T> data, int pageSize, int pageIndex, int itemsCount)
        {
            this.pageIndex = pageIndex;
            this.pageSize = pageSize;
            this.itemsCount = itemsCount;
            this.AddRange(data);
        }

        public bool HasPreviousPage
        {
            get
            {
                return (pageIndex > 0);
            }
        }

        public bool HasNextPage
        {
            get
            {
                return (pageIndex + 1 < itemsCount);
            }
        }
    }
}
